#pragma once
#include <stdexcept>
using namespace std;
template<typename T>
class MyArray
{
public:

	MyArray(size_t size) :mSize(size), mArray(nullptr)
	{
		mArray = new  T[size];
	}
	~MyArray()
	{
		if (mArray)
		{
			delete[] mArray;
			mArray = nullptr;
		}
	}
	size_t getSize() const
	{
		return mSize;
	}

	T& at(size_t index) noexcept(false)
	{
		if (index >= 0 && index < getSize())
			return mArray[index];
		else
			throw out_of_range("MyArray::at:Index out of range.");
	}
protected:
	size_t mSize;
	T* mArray;
};
